#ifndef __GD32_INIT_H__
#define __GD32_INIT_H__

#include "gd32f4xx.h" // Device header
#include "QueueLIB.h"

#define ENET_IP_ISCONFIG 0X00000001U
#define ENET_PHY_LINK_UP 0X00000002U

typedef struct
{
    uint8_t Protocol;
    uint8_t Port;
    uint16_t Stattion;
} CommSetting, *pCommSetting;

typedef struct
{
    uint8_t BaudRate;
    uint8_t CheckBit;
    uint8_t DataBit;
    uint8_t StopBit;
} UartConfig, *pUartConfig;

enum
{
    CF_RS485_1 = 0x01,
    CF_RS485_2,
    CF_RS232,
    CF_RS422,
    CF_ProfiBus,
    CF_CAN,
    CF_ENet,
};

enum
{
    PRO_MODBUS_RTU = 0x01,
    PRO_PROFIBUS,
    PRO_TCP,
    PRO_CANBUS,
};

extern can_receive_message_struct receive_message;
extern can_trasnmit_message_struct transmit_message;

extern CommSetting ComUse;
extern UartConfig Rs485_1;
extern UartConfig Rs485_2;
extern UartConfig Rs422;
extern UartConfig Rs232;

extern APIHANDLE UartRxQueue0, UartRxQueue1, UartRxQueue2, UartRxQueue3, UartRxQueue4, USBRxQueue, ENetRxQueue;
extern APIHANDLE UartTxQueue0, UartTxQueue1, UartTxQueue2, UartTxQueue3, UartTxQueue4, USBTxQueue, ENetTxQueue;

void usb_intr_config(void);
void GD32_Init(void);
void CANBus_Init(void);

#endif
